package com.xsp.statistics.controller;


import com.xsp.commonutils.R;
import com.xsp.statistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author xsp
 * @since 2022-03-04
 */
@RestController
@RequestMapping("/statistics/daily")
public class StatisticsDailyController {

    @Autowired
    StatisticsDailyService dailyService;

    //统计某天注册人数，生成统计数据
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        dailyService.registerCount(day);
        return R.ok();
    }

    //获取图表统计数据
    @GetMapping("showChart/{type}/{begin}/{end}")
    public R showChart(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String,Object> map = dailyService.getChartData(type,begin,end);
        return R.ok().data(map);
    }
}

